package com.landinfo.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;


/**
 * 飞行管理
 * Create by lzq
 * 2017-06-06
 */
@ApiModel(description = "飞行管理 Create by lzq 2017-06-06")
@Entity
@Table(name = "fly_to")
// @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class FlyTo implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
    @SequenceGenerator(name = "sequenceGenerator")
    private Long id;

    /**
     * 名称
     */
    @NotNull
    @Size(max = 100)
    @ApiModelProperty(value = "名称", required = true)
    @Column(name = "name", length = 100, nullable = false)
    private String name;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Column(name = "remark")
    private String remark;

    /**
     * 所属用户
     */
    @ApiModelProperty(value = "所属用户")
    @Column(name = "user_id")
    private String userId;

    /**
     * 缩略图
     */
    @ApiModelProperty(value = "缩略图")
    @Lob
    @Column(name = "thumbnail")
    private String thumbnail;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @Column(name = "create_date")
    private ZonedDateTime createDate;

//    @OneToMany(mappedBy = "flyTo")
//    @JsonIgnore
//    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumns(value={@JoinColumn(name="flyto_id",referencedColumnName="id")})
    private Set<FlyToLine> flyToLines = new HashSet<>();

    // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public FlyTo name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public FlyTo remark(String remark) {
        this.remark = remark;
        return this;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getUserId() {
        return userId;
    }

    public FlyTo userId(String userId) {
        this.userId = userId;
        return this;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getThumbnail() {
        return thumbnail;
    }

    public FlyTo thumbnail(String thumbnail) {
        this.thumbnail = thumbnail;
        return this;
    }

    public void setThumbnail(String thumbnail) {
        this.thumbnail = thumbnail;
    }

    public ZonedDateTime getCreateDate() {
        return createDate;
    }

    public FlyTo createDate(ZonedDateTime createDate) {
        this.createDate = createDate;
        return this;
    }

    public void setCreateDate(ZonedDateTime createDate) {
        this.createDate = createDate;
    }

    public Set<FlyToLine> getFlyToLines() {
        return flyToLines;
    }

    public FlyTo flyToLines(Set<FlyToLine> flyToLines) {
        this.flyToLines = flyToLines;
        return this;
    }



    public void setFlyToLines(Set<FlyToLine> flyToLines) {
        this.flyToLines = flyToLines;
    }
    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        FlyTo flyTo = (FlyTo) o;
        if (flyTo.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), flyTo.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "FlyTo{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            ", remark='" + getRemark() + "'" +
            ", userId='" + getUserId() + "'" +
            ", thumbnail='" + getThumbnail() + "'" +
            ", createDate='" + getCreateDate() + "'" +
            "}";
    }
}
